package com.lm.artemis.producer;

import jakarta.jms.Queue;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

@Service
public class MsgProducer {

    private final JmsMessagingTemplate jmsMessagingTemplate;
    private final Queue queue;

    public MsgProducer(JmsMessagingTemplate jmsMessagingTemplate, Queue queue) {
        this.jmsMessagingTemplate = jmsMessagingTemplate;
        this.queue = queue;
    }

    public void send(String msg) {
        System.out.println("发送消息: " + msg);
        jmsMessagingTemplate.convertAndSend(queue, msg);
    }
}
